package com.sinosoft.msf.base.supplier.controller;

import cn.hutool.core.lang.Validator;

import com.sinosoft.msf.base.supplier.pojo.EnterpriseInfoPojo;
import com.sinosoft.msf.base.supplier.pojo.RestEntity;
import com.sinosoft.msf.base.supplier.pojo.tyc.QueryVo;
import com.sinosoft.msf.base.supplier.service.TycService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tianyancha")
public class TycController {
    @Autowired
    TycService tycService;
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @PostMapping(value = "/query/info", name = "查询天眼查")
    public RestEntity addCompany(@RequestBody QueryVo queryVo) {
        Validator.validateNotEmpty(queryVo.getQueryType(), "查询类型不可为空");
        Validator.validateNotEmpty(queryVo.getQueryValue(), "查询关键字不可为空");
        EnterpriseInfoPojo infoPojo = tycService.queryAllInfo(queryVo);
//        EnterpriseInfoPojo infoPojo = tycService.queryAllInfo2(queryVo);
        return RestEntity.data(infoPojo);
    }

    @PostMapping(value = "/query/license", name = "查询营业执照")
    public RestEntity licenseQuery(@RequestBody QueryVo queryVo) {
        Validator.validateNotEmpty(queryVo.getComId(), "公司ID不可为空");
        return RestEntity.data(tycService.tycLicense(queryVo.getComId()));
    }
    @PostMapping(value = "/query/invest", name = "查询股权穿透图列表")
    public RestEntity investQuery(@RequestBody QueryVo queryVo) {
        Validator.validateNotEmpty(queryVo.getComId(), "公司ID不可为空");
        return RestEntity.data(tycService.investtree(queryVo.getComId(),queryVo.getSource()));
    }

}
